Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services
Imports System.Collections.Generic
Imports Security.Data
Imports Security.Entities

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<ScriptService()> _
Public Class Autocomplete
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function GetRoles(ByVal prefixText As String, ByVal count As Integer) As String()
        If count = 0 Then
            count = 10
        End If

        Dim result As New List(Of String)
        Dim dao As New RoleDAO()
        Dim roles As IList(Of Role)

        roles = dao.ListByName(prefixText + "%")

        For Each r As Role In roles
            result.Add(r.RoleName)
        Next

        Return result.ToArray()
    End Function

    <WebMethod()> _
    Public Function GetGroups(ByVal prefixText As String, ByVal count As Integer) As String()
        If count = 0 Then
            count = 10
        End If

        Dim result As New List(Of String)
        Dim dao As New GroupDAO()
        Dim groups As IList(Of Group)

        groups = dao.ListByName(prefixText + "%")

        For Each r As Group In groups
            result.Add(r.GroupName)
        Next

        Return result.ToArray()
    End Function

End Class
